<?php
	class Property_model extends Model
		{
			function Property_model()
			{
				parent::Model();
			}
			
			function fetchpropertytype()
			{
				$testarr=array();
				$qry="select * from property_type";
				$rs=$this->db->query($qry);
				if($rs->num_rows()>0)
				{
					foreach($rs->result() as $row)
					{
						$testarr[]=array('typeid'=>$row->typeid,'propertytype'=>$row->propertytype);
					}
				}
				return $testarr;
			}
			
			function fetchcitylist()
			{
				$testarr=array();
				$qry="select * from citylist order by cityname";
				$rs=$this->db->query($qry);
				if($rs->num_rows()>0)
				{
				foreach($rs->result() as $row)
                {
                    $cityid = $row->cityid;
					$cityname=$row->cityname;
                    $qry = "select * from city_locality where cityid = ? order by locality";
					$rs=$this->db->query($qry,array($cityid));
                    $localityarray = array();
					if($rs->num_rows()>0)
					{
                    foreach($rs->result() as $row)
                    {
                        $localityarray[] = array("localityid"=>$row->localityid,"locality"=>$row->locality);
                    }
					}
                   $testarr[]= array("cityname"=>$cityname , "localityarray"=>$localityarray);           
                }}
				return $testarr;
			}
			
			function fetchpropertyminbudget()
			{
				$testarr=array();
				$qry="select * from propertybudget";
				$rs=$this->db->query($qry);
				if($rs->num_rows()>0)
				{
					foreach($rs->result() as $row)
					{
						$testarr[]=array('budgetid'=>$row->budgetid,'budget'=>$row->budget,'budgetname'=>$row->budgetname);
					}
				}
				return $testarr;
			}
			
			function fetchpropertymaxbudget()
			{
				$testarr=array();
				$qry="select * from propertybudget where budget>500000";
				$rs=$this->db->query($qry);
				if($rs->num_rows()>0)
				{
					foreach($rs->result() as $row)
					{
						$testarr[]=array('budgetid'=>$row->budgetid,'budget'=>$row->budget,'budgetname'=>$row->budgetname);
					}
				}
				return $testarr;
			}
			
			
			
		}
?>